package main

import "fmt"

func funRetrunOne() int {
	return 1
}

func funReturnMore(a, b int, c string) {
	a = a + 1
	b = b + 1
	c = "cm2023"
	return
}

func funReturnName(res int) {
	res = 1 + 1
	return
}

func noChange(a, b int) {
	tmp := a
	a = b
	b = tmp
}

func change(a, b *int) {
	tmp := *a
	*a = *b
	*b = tmp
}

func functionValue(a, b int, do func(int, int) int) {
	fmt.Println(do(a, b))
}

func add(a, b int) int {
	return a + b
}

func sub(a, b int) int {
	return a - b
}

// https://golang-minibear2333.github.io/2.func-containers/2-1-func/
func main() {
	// 加法
	functionValue(2, 1, add)
	// 减法
	functionValue(2, 1, sub)
	// 匿名内部函数写法
	functionValue(2, 3, func(i1 int, i2 int) int {
		return i1 * i2
	})
}
